package com.lubase.wfengine.consumer.rocket;

import com.lubase.wfengine.auto.entity.WfTEventEntity;
import com.lubase.wfengine.consumer.ProcessEngineEventService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

@RocketMQMessageListener(topic = "${lubase.wf-engine.engine-topic:LUBASE_WF_ENGINE_TOPIC}", consumerGroup = "${lubase.wf-engine.engine-consumer-group:LUBASE_WF_ENGINE}")
@Service
@Slf4j
@ConditionalOnProperty(name = "lubase.wf-engine.mq-type", havingValue = "rocketmq")
public class EngineEventProcessRocketMQConsumer implements RocketMQListener<WfTEventEntity> {

    @Autowired
    ProcessEngineEventService processEngineEventService;

    public void onMessage(WfTEventEntity entity) {
        processEngineEventService.processWftEvent(entity);
    }
}
